<?php

class HiringcompanyController extends AdminController {    
    
    public function actionIndex() {
        $model = new HiringCompany('search');
        $model->unsetAttributes();  // clear any default values
        if (isset($_GET['HiringCompany']))
            $model->attributes = $_GET['HiringCompany'];
        $this->render('index', array(
          'model' => $model,
        ));
	
    }
    
    function actions() {
        return array(
          'create' => array(
            'class' => 'lib.components.actions.CreateAction',
            'modelClass' => 'HiringCompany',
        	'jsFunction' => 'processAfterNewHiring',
            'messages' => array('success' => t('MSG_INFO_INSERT_SUCCESS', 'messages' , array('{0}' => t('LBL_HIRING_COMPANY', 'hiringCompany'))))
          ),
          'update' => array(
            'class' => 'lib.components.actions.UpdateAction',
            'modelClass' => 'HiringCompany',
            'messages' => array('success' => t('MSG_INFO_UPDATE_SUCCESS', 'messages', array('{0}' => t('LBL_HIRING_COMPANY', 'hiringCompany'))))
          ),
          'delete' => array(
            'class' => 'lib.components.actions.DeleteAction',            
            'ajaxView' => "//share/_delete",
            'messages' => array('success' => t('MSG_INFO_DELETE_SUCCESS', 'messages' , array('{0}' => t('LBL_HIRING_COMPANY', 'hiringCompany'))))
          ),
          'error' => array(
            'class' => 'lib.components.actions.ErrorAction',
          ),
        );
    }	  
    
    public function loadModel() {
        $model = null;
        if (isset($_GET['id']))
        {
            $ids = explode(',', $_GET['id']);
            if (isset($ids)) {
                $criteria = new CDbCriteria;
                $criteria->addInCondition('id', $ids);
                $model = HiringCompany::model()->findAll($criteria);
            }         
        }
        return $model;
    }
    
    public function actionDetail()
    {    	
		$id = $_GET['id'];
		$model = HiringCompany::model()->getChtmlDropdownDataById($id);	
        echo CJSON::encode(JSonUtils::convertModelToArray($model[0]));
        Yii::app()->end();
    }

    public function editDialogButtonHtml($hiringCompanyModel, $dialogTitle, $dialogWidth, $dialogHeight) {
	$updateUrl = url(app()->controller->id . "/update/" . $hiringCompanyModel->id);

	return Html::buttonInGrid('linkEdit', $updateUrl, 'Edit', $dialogTitle, 'icon edit update-dialog-open-link', $dialogWidth, $dialogHeight);
    }
}

?>